/*
 * Copyright (c) 2011 Jean-Marc Perronne
 * Ensisa, 12 rue des Freres Lumieres, F-68093 Mulhouse cedex
 * All rights reserved.
 *
 * The copyright of this software is owned by Werner Randelshofer. 
 * You may not use, copy or modify this software, except in  
 * accordance with the license agreement you entered into with  
 * Jean-Marc Perronne. For details see accompanying license terms. 
 */

package fr.uha.ensisa.jmp.drone.navdata.options;

import fr.uha.ensisa.jmp.drone.navdata.NavdataOption;

public class VisionDetect extends NavdataOption
{
	public static final int NB_NAVDATA_DETECTION_RESULTS = 4;
	
	public long nb_detected; 	// uint
	public long type[]; 		// uint
	public long xc[]; 			// uint
	public long yc[]; 			// uint
	public long width[]; 		// uint
	public long height[];		// uint
	public long dist[];			// uint
	public float orientation_angle[];			


	public VisionDetect()
	{
		this.allocate();
	}

	public VisionDetect(VisionDetect tags)
	{
		this.nb_detected = tags.nb_detected;
		this.allocate();
		System.arraycopy(tags.type, 0, this.type, 0, tags.type.length);
		System.arraycopy(tags.xc, 0, this.xc, 0, tags.xc.length);
		System.arraycopy(tags.yc, 0, this.yc, 0, tags.yc.length);
		System.arraycopy(tags.width, 0, this.width, 0, tags.width.length);
		System.arraycopy(tags.height, 0, this.height, 0, tags.height.length);
		System.arraycopy(tags.dist, 0, this.dist, 0, tags.dist.length);
		System.arraycopy(tags.orientation_angle, 0, this.orientation_angle, 0, tags.orientation_angle.length);
	}

	private void allocate()
	{
		this.type = new long[NB_NAVDATA_DETECTION_RESULTS];
		this.xc = new long[NB_NAVDATA_DETECTION_RESULTS];
		this.yc = new long[NB_NAVDATA_DETECTION_RESULTS];
		this.width = new long[NB_NAVDATA_DETECTION_RESULTS];
		this.height = new long[NB_NAVDATA_DETECTION_RESULTS];
		this.dist = new long[NB_NAVDATA_DETECTION_RESULTS];
		this.orientation_angle = new float[NB_NAVDATA_DETECTION_RESULTS];
	}
	@Override
	public void accept(OptionsVistor v)
	{
		v.visitVisionDetect(this);
	}
	
	public String toString()  
	{
		StringBuilder tmp = new StringBuilder(getClass().getName() + "[");
        tmp.append("nb_detected=").append(this.nb_detected);
        
        tmp.append(", type=[");
        for(int i=0; i< this.type.length; i++)
        	tmp.append(this.type[i]).append (' ');
        tmp.append(']');
        		
        tmp.append(", xc=[");
        for(int i=0; i< this.xc.length; i++)
        	tmp.append(this.xc[i]).append (' ');
        tmp.append(']');
        
        tmp.append(", yc=[");
        for(int i=0; i< this.yc.length; i++)
        	tmp.append(this.yc[i]).append (' ');
        tmp.append(']');

        tmp.append(", width=[");
        for(int i=0; i< this.width.length; i++)
        	tmp.append(this.width[i]).append (' ');
        tmp.append(']');

        tmp.append(", height=[");
        for(int i=0; i< this.height.length; i++)
        	tmp.append(this.height[i]).append (' ');
        tmp.append(']');
     
        tmp.append(", dist=[");
        for(int i=0; i< this.dist.length; i++)
        	tmp.append(this.dist[i]).append (' ');
        tmp.append(']');

        tmp.append(", orientation=[");
        for(int i=0; i< this.orientation_angle.length; i++)
        	tmp.append(this.orientation_angle[i]).append (' ');
        tmp.append(']');
        
        tmp.append(']');
        return tmp.toString();
    }
}
